﻿package com.alipay.config;

import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */

public class AlipayConfig {
	
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

	// 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
	public static String app_id = "2016091600520902";
	
	// 商户私钥，您的PKCS8格式RSA2私钥,我们加密密钥
    public static String merchant_private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCbPVmcqloEh0rMtsQJElVaF2jOTZtx+EJCk+PUPwY0xSR+njuJ/Mc3ODvZlj6FnQNp21DobbAQhSHJKotxe7pnLcaMjbB5Myr1SYbMkCZqGKcPtP1nYDdEKSA/3xte6P0Cw5Qt5LDOT1wgK5sCpAiL9KmeidhNviD4D23rZv9KcsyI/c5LSQ2JCrngbiva9xh/JQ5SJ7nauYxzgk6fWdKMzD1Xlpvktpvl7NtIWjs8SM7RcvF4IRQVRardYBrq+hm7iRRQL1WQ+aVj7HG0I4jf984eH+lOtRIml2X38/FxTmqBBGVsaYIBTC7zwOadjxvXVraRD5WDnRBLxZXSoP/BAgMBAAECggEAaOPN/Z3YjsC/GIzQ7fQ2OVYh2Wr0gdAlLQjx4kHnNpaRrv/I6NYj4LqdLcpnWi4Z1Vd7VmBumurpRhv59eaMrxRt2CAQQgQBnZRdgTBQ1FTt5B39LfEDxoknIiDkRH+WHFz7bPrdP7i9XXs5FFKy96WLSfSHcxfo/NKoCWshSTIudhzzJFq9IdzB0t8KGcuSl5y2brH286Kipi5rEdzeSrTw+Gg5kxuhoM3rK0lgU0MNVF5vjLu2QyZ44rveVscncbp9pCtobgsrcOUp+Iq6kqajjSUOINgsK8PLJoUow7B2XjGhCMxE+YCxos17bg4UXtnVzueovuL/RBk/LfMMNQKBgQD2Oru0138wfG/cyAlcpokcCE+EzvkqBjb0Ut+aA4m3B5l143w4r/XmO7GFLkQfvvNv82nPPYu2yZa86LMZuIxim67qsSJwaPLALL9jknzhUNWVmpMgkKGefRIx2zftnjFrhHgeavGXyRc8AQlVCn7ld7TOrckb5cuIyLtZ270GSwKBgQChZlFDHzKj5eNy/nQ9X5shO2C886R3hyu6qnFuLIYlnelyGNPQ1wgUsGQ1wqW9QFhDeSjp7JZCs9/uZ8+fWG0LHYFgrCOMZltlsqkEjD3osz4BG4YynYOhnKywp/fxHJGTKAvSfNykpLYhZ0iwQh9roYUxOAOpvgh8MQ2Ojes6owKBgGmKdUinken7fIs65uBitaRhX4xClwRPU6DYIOXIHHBqfnnMf0NhENqVvZqjYSnmVDwpLrJY5Bj+QXFJoPMmam4d4xTPxj4+jcaXp5WLhaGiX1pXvjaYJ95iJ7ldCJT+WJqIVmBbYKC53g6nNxPPguLis4pfbTNbBSnlOIDkshoPAoGAP8FLGFiaiGOnFSWuhQ/fF6F89SbJMO4UOAhcBklQNEvMi2WDRluqtYF4FERvc/KW6xBRORZbxL2JF4OqYCdt65YcJTPaVvuX3vRUD5fWXLVxKL7Wo+fUt2JMVPwE1RmT561J/juUbPUjfM5vyDBWeQ20r1yRFdwbPfOih01IPkECgYEA8AoM83XLr9W7AoWuH/GXy8a3/BnTzXE8yfdMHWBfllEXvWIIfmsjKibn+hfpezwJHNm1NeAF8A1GTYNNk5tDMFtPIJ7SNHtA9CaZSwLFq/6s1vWPVTZ7wUsB8Gp0vagPDZLk3+qk8X9reCWBRHM1Xp5av8WlGLKaHmJAQ8f8XTc=";
	
	// 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvijIWc+O02JmoJDD0R2RZr8s+SbK+Cl1/fa2zH8deHePH5dmR3agalEtKkTrS3Z0WpoOMpqdNj4TmOh3/awbVGpJzMSNWHxwyY3iFcgGFKSVfZjZPu0KllpaPuLwhN8YeKEn0f8k51NefAO1lLkvIZ4eStzKHNoBlSCQGFAmpHw4u/sS4/RUve/2iYnWTTscnZv0eVmz3PbFOQNNHoJUGtjgZ0h8Fd0LcViXOo3nLv2abR8krqRw1YC3GzvNsyDYEFS+HV6aKECgc2eZsGXsy6QW0EW2wyvsbXVsXctp0zfvXFl/Ruw/QoCPts197v/94+C7bJeDwkzIqgf12EJM7wIDAQAB";

	// 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String notify_url = "http://qns9qk.natappfree.cc/alipay/notify_url.jsp";

	// 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String return_url = "http://qns9qk.natappfree.cc/alipay/return_url.jsp";

	// 签名方式
	public static String sign_type = "RSA2";
	
	// 字符编码格式
	public static String charset = "utf-8";
	
	// 支付宝网关
	public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";
	
	// 支付宝网关
	public static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /** 
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

